#!/usr/bin/perl
#
# Extract data for plotting from campus scenario debug output
#

open(EPIDEMIC, "> campus_epidemic_growth.txt") 
    or die "Couldn't open output file campus_epidemic_growth.txt: $!\n";
open(INFECTIONS, "> campus_infections.txt")
    or die "Couldn't open output file campus_infections.txt: $!\n";

while (<>) {
    if (/infected/) {
	my ($t) = /t: ((\d|\.)+)/;
	print INFECTIONS "$t\n";
    } else {
	if (/Macroscopic model update/) {
	    my ($t, undef, $i) = /t: ((\d|\.)+)\s.*?i=((\d|\.)+)/;
	    print EPIDEMIC "$t  $i\n";
	}
    }
}
